package com.lj.ljminsu.houseDetails.controller;

import com.lj.ljminsu.houseDetails.bean.UserInfo;
import com.lj.ljminsu.houseDetails.service.UserOrderService;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

@RestController
@RequestMapping("order")
@CrossOrigin
public class OrdersController {
    @Resource
    private UserOrderService userOrderService;
    //订单页获取用户信息
    @RequestMapping("{userHouse}")
    public UserInfo userInfo(@PathVariable("userHouse") String userHouse){
        //userHouse 为 用户id-房子id
        String[] split = userHouse.split("-");
        String userId = split[0];
        String houseId = split[1];
        UserInfo userInfo = userOrderService.queryUserInfoByUserIdAndHouseId(Integer.parseInt(userId), Integer.parseInt(houseId));
        return userInfo;
    }
}
